<?php
/**
 * Created by PhpStorm.
 * User: lgy
 * Date: 2018/6/30
 * Time: 15:50
 */

namespace app\admin\model;
use think\Db;
use think\Model;

class Admin extends Model
{
	//检查登录
	public static function checkAdmin(){

	}
	//获取所有管理员 暂时不分页
	public static function getAdmin(){
		$condition = [
			'status'=>1
		];
		$order = [
			'create_time'=>'DESC'
		];
		$result =  Db::table('dbkj_admin')->where($condition)->order($order)->select();
		return $result;
	}
	//添加管理员
	public static function addAdmin($params){
//		self::levelCheck($params);
		$insert = [
			'username'=>$params['username'],
			'password'=>psMD5($params['password']),
			'level'=>$params['level'],
			'nickname'=>$params['nickname'],
			'content'=>$params['content'],
			'ip'=>getIP(),
			'phone'=>$params['phone'],
			'create_time'=>time(),
			'update_time'=>time(),
			'status'=>1
		];
		$result = Db::table('dbkj_admin')->insert($insert);
		return $result;
	}
	//检测是否越级
	public static function levelCheck($params){
		$level = $params['level'];
		if($level < 64){
			abort(404,'没有权限');
		}
	}
}